<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hasPlugin</title>
</head>

<body>
    <p>打开浏览器查看结果</p>
    <script>
        const hasPlugin = () => {
            const hasOtherBrowserPlugin = pluginName => {
                pluginName = pluginName.toLowerCase();
                for (let plugin of window.navigator.plugins) {
                    const _plugin = typeof plugin === 'string' ? plugin : plugin.name;
                    if (_plugin.toLowerCase().indexOf(pluginName) > -1) {
                        return true;
                    }
                }
                return false;
            };
            const hasIEPlugin = pluginName => {
                try {
                    new ActiveXObject(pluginName);
                    return true;
                } catch (ex) {
                    return false;
                }
            };
            return {
                hasOtherBrowserPlugin,
                hasIEPlugin
            };
        };
        const { hasOtherBrowserPlugin, hasIEPlugin } = hasPlugin();
        console.log(hasOtherBrowserPlugin('flash'), hasOtherBrowserPlugin('QuickTime'), hasOtherBrowserPlugin('pdf'));
        // ie浏览器中查看这个
        // console.log(hasIEPlugin('ShockwaveFlash.ShockwaveFlash'))
    </script>
</body>

</html>